<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<style>
#link { background-color: red }
#link:any-link { background-color: green }
#link + div { color: pink }
</style>
<a id="link">This link should have a green background.</a>
<div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</div>
<script>
description("Use descendant invalidation set for :any-link pseudo class.")

var red = "rgb(255, 0, 0)";
var green = "rgb(0, 128, 0)";

shouldBe("getComputedStyle(link).backgroundColor", "red");

link.offsetTop; // Force recalc.
link.href = "not-visited.html";

if (window.internals)
    shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1");

shouldBe("getComputedStyle(link).backgroundColor", "green");
</script>
